<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./../template/WorkspaceTemplate.xhtml">

    <ui:define name="top">

    </ui:define>

    <ui:define name="left">

    </ui:define>

    <ui:define name="right">

    </ui:define>

    <ui:define name="content">
        <style>
            .ui-state-highlight.ui-selected {
                color: blueviolet;
            }
        </style>

        <h2>View Customer Payment Record</h2>

        <h:form id="searchCPRForm" >
            <p:panel style="height: 250px"> 
                <p:messages />

                <h:panelGrid columns="3" cellpadding="10">
                    <h:outputLabel style="font-weight: bold" value="Enter Customer Payment Record ID: "/>
                    <h:inputText required="true" requiredMessage="Customer Payment Record Id is required." value="#{cprManagerBean.selectedCpr.customerPaymentRecordId}"/>
                    <p:commandButton update="searchCPRForm" oncomplete="cprDialog.show();" image="ui-icon ui-icon-search"/>    
                </h:panelGrid>
                <p:commandButton id="button" value="Next" action="#{cprManagerBean.viewCustomerPaymentRecord()}"/>
            </p:panel>
        </h:form>


        <p:dialog header="Search Customer Payment Record" widgetVar="cprDialog" hideEffect="explode" height="600" width="800">    
            <h:form id="searchCustomerPaymentRecordForm">
                <p:dataTable var="cpr" value="#{cprManagerBean.cprs}"
                             emptyMessage="No Customer Payment Record found with given criteria" selection="#{cprManagerBean.selectedCpr}" selectionMode="single" widgetVar="sotbl">

                    <p:column filterBy="#{cpr.customerPaymentRecordId}" 
                              headerText="Customer Payment Record Id">
                        <h:outputText value="#{cpr.customerPaymentRecordId}" />
                    </p:column>

                    <p:column filterBy="#{cpr.paymentDate}" 
                              headerText="Payment Date">
                        <h:outputText value="#{cpr.paymentDate}">
                            <f:convertDateTime pattern="MMMM dd, yyyy"/>
                        </h:outputText>
                    </p:column>
                </p:dataTable>
                <p:commandButton value="Select Customer Payment Record" update="searchCPRForm" oncomplete="cprDialog.hide()"/>
            </h:form>
        </p:dialog>
    </ui:define>

    <ui:define name="bottom">

    </ui:define>

</ui:composition>
